<!-- 资产状态 -->
<template>
  <div class="dashboard-editor-container">
    <div class="xxx" style="margin-top: 10px;">
      
      <el-tabs type="border-card" :style="{ width:'100%'}" @tab-click="handleClick">
        <el-tab-pane label="列表看板">
          <div style="display:flex;justify-content:space-between;">
            <partitionTree :nodeData="nodeData" :addTemplate="false" :expandArray="expandArray" :defaultExpandAll="false" @handleNodeClick="handleNodeClick" ref="partitionTree" @toggleVisibility="toggleVisibility"></partitionTree>
            <div :style="{ width:containerWidth}"  class="box" style="background:#fff;padding:20px;border: 1px solid #ddd;border-radius: 4px;box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);">
              <connsearch ref="connsearch" :formOptions="formOptions" @search="search" @reset="reset">
                <el-button type="warning" size="small" @click="restart_Device(false)">批量远程操作</el-button>
              </connsearch>
              <el-table stripe border :data="tableData" style="width: 100%; margin-top: 15px" height="640px" ref="table">
                <el-table-column label="序号" width="80" type="index" :index='(index) => { return (index + 1) + (pageNum - 1) * pageSize }'> </el-table-column>
                <el-table-column label="资产名称" prop="DeviceName" width="180" align="left" show-overflow-tooltip></el-table-column>
                <el-table-column label="所在部门" prop="Department"  align="left" show-overflow-tooltip />
                <el-table-column label="所在教室" prop="ClassName"  align="left" show-overflow-tooltip />
                <el-table-column label="资产备注" prop="UseName"  align="left" show-overflow-tooltip></el-table-column>
                <el-table-column label="操作系统" prop="DeviceClass"  align="left" show-overflow-tooltip></el-table-column>
                <el-table-column label="资产类型" prop="DeviceType"  align="left" show-overflow-tooltip></el-table-column>
            <el-table-column label="在线状态" prop="StatusChangeTime" width="160" align="left" show-overflow-tooltip>
                  <template slot-scope="{row}">
                    <span>
                      <span style="color:#67C23A" v-if="row.Status === 1" type="success">在线</span>
                      <span style="color:#F56C6C" v-if="row.Status !== 1" type="danger">离线</span>
                      <span v-if="!row.LastReportStatusTime || !row.StatusChangeTime">--初始化</span>
                      <span v-else-if="row.StatusChangeTime_redo">--{{row.StatusChangeTime_redo}}</span>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column label="运行时长" prop="KeepRunningTime"  align="left" show-overflow-tooltip />
                <!-- <el-table-column label="今日事件" prop="TodayEventCount"  align="left" show-overflow-tooltip /> -->
                <el-table-column label="操作" width="180px"  fixed="right" class="el-table__fixed"> 
                  <!-- <template slot="header">
                    <el-button type="warning" size="mini" @click="restart_Device(false)">批量远程操作</el-button>
                  </template> -->
                  <template slot-scope="scope"> 
                    <el-button type="primary" size="mini" @click="LookDetails(scope.row)">详情</el-button>
                    <el-button :type="scope.row.Status === 1 ? 'warning' : 'info'" size="mini" :disabled="scope.row.Status !== 1" @click="operateDevice(scope.row)">远程操作</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <el-pagination 
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange" 
                :current-page=pageNum
                :page-size=pageSize
                background 
                layout="total, prev, pager, sizes, next, jumper"
                :total="total">
              </el-pagination>
            </div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="拓扑看板">
          <vue2-org-tree 
          :data="tableData2" 
          :renderContent="renderContent"
          :horizontal="true" 
          @on-expand="onExpand"
          @on-node-click="NodeClick"
          collapsable
          style="width:100%;">
        </vue2-org-tree>
        </el-tab-pane>
      </el-tabs>
    </div>
    <el-dialog v-el-drag-dialog  :fullscreen="dialogFull"  title="远程操作" :close-on-click-modal="false" :visible.sync="dialogDeviceVisible" width="40%">
      <template slot="title">
        <div class="avue-crud__dialog__header">
            <span class="el-dialog__title">
              远程操作
            </span>
          <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
            <i class="el-icon-full-screen"   v-if="dialogFull == false"/>
            <i class="el-icon-copy-document" v-else/>
          </div>
        </div>
      </template>
      <span  style="display:flex;margin-bottom:15px;justify-content: center;width:100%;">
        <span style="display: flex;justify-content: center;align-items: center;">远程命令：</span>
        <div style="display:flex;flex:1" >
          <el-select v-model="selectedOption" placeholder="请选择操作" @change="handleSelectChange(selectedOption)">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select> 
        <el-input v-if="show_shell" type="text" maxlength ="200"  clearable placeholder="请输入具体指令" v-model="ShellCmd"  style="margin-left:10px;flex:1"/> 
        <el-tooltip content="编辑指令" placement="top" v-if="show_shell">
          <i v-if="show_shell" class="el-icon-document" style="font-size:18px;cursor: pointer;display: flex;justify-content: center;align-items: center;" @click="editShell"> </i>
        </el-tooltip>
        </div>
      </span>
      <tree-transfer 
          :openAll="true"
          :title="['待选择','已选择']"
          :from_data='fromData' 
          :to_data='toData'               
          :defaultProps="{label:'label'}"
          ref="myTransfer" 
          :transferOpenNode="true"
          @add-btn='addSelect' 
          @remove-btn='removeSelect'
          :height="dialogFull? '640px':'320px'"
          filter     
          >  
      </tree-transfer>
      <span  style="display:flex;margin-top:15px;justify-content: center;width:100%;">
        <span style="display: flex;justify-content: center;align-items: center;">操作设备：</span>
        <span style="flex: 1;">
          <el-input type="textarea"   :autosize="{ minRows: 1, maxRows: 3}" resize="none" v-model="selectInfo" disabled />
        </span>
      </span>
      
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit()">确 定</el-button>
        <el-button type="info" @click="dialogDeviceVisible = false">取 消</el-button>
      </span> 
    </el-dialog>
    <el-dialog
      :close-on-click-modal="false"
      :close-on-press-escape=false
      title="编辑指令"
      :visible.sync="editShow"
      v-el-drag-dialog
      width="40%"
    >
      <el-input
        type="textarea"
        :rows="5"
        placeholder="请输入具体指令"
        v-model="ShellCmd"
        maxlength="200"
        show-word-limit
      >
      </el-input>
      <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="editShow = false">确 定</el-button>
    </span>
    </el-dialog>
  </div>
</template>

<script> 
import Vue2OrgTree from "vue2-org-tree";
import 'vue2-org-tree/dist/style.css'
import Cookies from 'js-cookie'
import connsearch from "@/components/connSearch";
import linechart from "@/views/logAnalysis/components/linechart.vue"
import { connrequest } from '@/api/firstPage'
import treeTransfer from 'el-tree-transfer'
import { parseTime, getuuid, recursiveGetNodePath, recursiveGetChildNodePath,formatDuration,getNowDay,bytesToSize ,formatTime2,formatBytes_back} from '@/utils/index'
import elDragDialog from "@/directive/el-drag-dialog"; 
import partitionTree from "@/components/partitionTree"; 
import assetsInfo from "@/components/assetsInfo"
import HardDetail from "@/components/HardDetail"
export default {
  directives: { elDragDialog ,treeTransfer},
  components: {
    partitionTree,connsearch,linechart,treeTransfer,Vue2OrgTree,assetsInfo,HardDetail
  },
  data() {
    let that = this
    return {  
      ShellCmd:'',
      editShow:false,
      selectInfo:'',
      show_shell:false,
      dialogFull:false,
      activeTab:'tab1',
      moderVisible:false,
      pageNum: 1,
      pageSize: 10,
      pageNum_net: 1,
      pageSize_net: 10,
      total_net:0,
      pageNum2: 1,
      pageSize2: 10,
      total2: 0,
      pageNum_app: 1,
      pageSize_app: 10,
      Device_pageNum: 1,
      Device_pageSize: 10,
      total: 0,
      containerWidth: 'calc(100% - 240px)',
      tableData: [],
      nodeData: [],
      Action: 1,
      Moder: {},
      dialogTableVisible: false,
      dialogDeviceVisible: false,
      reSource: [],
      tableData2:{},
      partitionList: [],
      partitionList_soft: [],
      choseArea: {},
      rules:{
        SchoolID: [
          {required: true, message: '请选择校区编码', trigger: 'blur'}
        ],
        SchoolName: [
          {required: true, message: '请选择校区名称', trigger: 'blur'}
        ],
        PrimArea: [
          {required: true, message: '请选择上级分区', trigger: 'change'}
        ],
        SecondArea: [
          {required: true, message: '请输入分区名称', trigger: 'blur'}
        ],
        AreaCode: [
          {required: true, message: '请输入分区编码', trigger: 'blur'}
        ],
        ClassName: [
          {required: true, message: '请输入教室', trigger: 'blur'}
        ],
        Phone: [
          {required: true, message: '请输入联系电话', trigger: 'blur'},
          {
            validator: function(rule, value, callback) {
              if (/^1[34578]\d{9}$/.test(value) == false && value) {
                callback(new Error("手机号格式错误"));
              } else {
                callback();
              }
            },
            trigger: "blur"
          }
        ],
        DeviceClass: [
          {required: true, message: '请选择操作系统', trigger: 'change'}
        ],
        DeviceType: [
          {required: true, message: '请选择资产类型', trigger: 'change'}
        ]
      },
      searchform:{},
      netInfo:{},
      formOptions: [
        {
          col: 7,
          label: "资产名称", // label文字
          prop: "DeviceName", // 字段名
          element: "el-input", // 指定elementui组件
          initValue: "", // 字段初始值,
          placeholder: "请输入资产名称,支持模糊查询。", // elementui组件属性
          maxlength: 50,
          rules: [], // elementui组件属性
          events: {
            input(val) {
              that.searchform.DeviceName = val
            },
          },
        },
        {
          col: 7,
          label: "资产编码", // label文字
          prop: "DeviceID", // 字段名
          element: "el-input", // 指定elementui组件
          initValue: "", // 字段初始值,
          placeholder: "请输入资产编码,支持模糊查询。", // elementui组件属性
          maxlength: 50,
          rules: [], // elementui组件属性
          events: {
            input(val) {
              that.searchform.DeviceID = val
            },
          },
        },
        {
          col: 7,
          label: "MAC地址", // label文字
          prop: "DeviceMAC", // 字段名
          element: "el-input", // 指定elementui组件
          initValue: "", // 字段初始值,
          placeholder: "请输入MAC地址,支持模糊查询。", // elementui组件属性
          maxlength: 50,
          rules: [], // elementui组件属性
          events: {
            input(val) {
              that.searchform.DeviceMAC = val
            },
          },
        },
      ],
      // formOptions: [
      //   {
      //     col: 4,
      //     hidden: false,
      //     label: "在线状态", // label文字
      //     prop: "Status", // 字段名
      //     element: "el-select", // 指定elementui组件
      //     initValue: 0, // 字段初始值,
      //     placeholder: "请选择在线状态", // elementui组件属性
      //     options: [
      //       { label: '全部', value: 0 },
      //       { label: '在线', value: 1 },
      //       { label: '离线', value: 2 }
      //     ],
      //     rules: [], // elementui组件属性
      //     events: {
      //       input(val) {
      //         that.searchform.Status = val
      //       }
      //     }
      //   },
      //   {
      //     col: 8,
      //     label: "分区校区选择",
      //     prop:"SchoolName",
      //     element: "el-cascader",
      //     initValue: "",
      //     placeholder: "请选择校区",
      //     options:[],
      //     props:{emitPath: true, checkStrictly: true, lazy: true, lazyLoad: that.lazyLoad},
      //     events: {
      //       input(val) {
      //         that.searchform.SchoolName = val
      //       },
      //     },
      //   },
      //   {
      //     col: 4,
      //     hidden: false,
      //     label: "排序字段", // label文字
      //     prop: "Sort_value", // 字段名
      //     element: "el-select", // 指定elementui组件
      //     initValue: "SchoolName", // 字段初始值,
      //     placeholder: "请选择排序字段", // elementui组件属性
      //     options: [
      //       { label: '校区名称', value: 'SchoolName' },
      //       { label: '在线状态', value: 'Status' },
      //       { label: '运行时长', value: 'KeepRunningTime' }
      //     ],
      //     events: {
      //       input(val) {
      //         that.searchform.Sort_value = val
      //       }
      //     }
      //   },
      //   // {
      //   //   col: 8,
      //   //   label: "资产编码", // label文字
      //   //   prop: "DeviceID", // 字段名
      //   //   element: "el-input", // 指定elementui组件
      //   //   initValue: "", // 字段初始值,
      //   //   placeholder: "请输入资产编码,支持模糊查询。", // elementui组件属性
      //   //   maxlength: 50,
      //   //   rules: [], // elementui组件属性
      //   //   events: {
      //   //     input(val) {
      //   //       that.searchform.DeviceID = val
      //   //     },
      //   //   },
      //   // },
       
      // ],
      expandArray: [],
      dialogForm:[],
      deviceForm:{},
      installTable:[],
      pageNum_int: 1,
      pageSize_int: 10,
      Total_int:0,
      illegalityTable:[],
      pageNum_ill: 1,
      pageSize_ill: 10,
      Total_ill:0,
      deficiencyTable:[],
      pageNum_def: 1,
      pageSize_def: 10,
      Total_def:0,
      devieceStaTable:[],
      pageNum_dev: 1,
      pageSize_dev: 10,
      Total_dev:0,
      EventTable:[],
      pageNum_event: 1,
      pageSize_event: 10,
      Total_event:0,
      netForm:[],
      eventTable:[],
      EventpageNum: 1,
      EventpageSize: 10,
      EventTotal:0,
      useSoftTable:[],
      useSoftpageNum: 1,
      useSoftpageSize: 10,
      useSoftTotal:0,
      BaseLineForm:[],
      BaseLineinfo:[],
      BashLineShow:false,
      BaselineResultList: [],
      total: 0,
      arr_divece:[],
      selectedSchools: [], // 存放选中学校的数组
      loading: false,
      selectMap:'',
      lineData_cpu:{
        time:[],downByte:[],info:''
      },
      lineData_soft:{
        time:[],downByte:[],info:''
      },
      fromData: [], // 存储传输的数据
      toData:[],    
      lastLevelLeafNodes: [],
      selectedOption: 200, // 设置默认选择第一个选项
      options: [
        { label: '强制关机', value: 200 },
        { label: '强制重启', value: 201 },
        { label: '强制注销', value: 202 },
        { label: '立即执行基线核查', value: 203 },
        { label: '强制刷新硬件和安装软件', value: 204 },
        { label: '执行网络隔离', value: 205 },
        { label: '解除网络隔离', value: 206 },
        { label: '开启远程控制', value: 207},
        { label: '停止远程控制', value: 208},
        { label: '发送通知', value: 209},
        { label: '执行指定命令', value: 210},
      ],
      eventList: [],
      SystemData:[],
      logDialognet: false,
      logList: [],
      operatedevice:{},
      schoolMap:''
    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.pageSize = Cookies.get('DefaultPageLength') * 1
    this.$set(this.searchform,'Status', 0)
    this.$set(this.searchform,'Sort_value','SchoolName' )
    this.getData()
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {
    this.GetParamDictEvent()
    this.getSystemData()
    // this.GetSchoolStatusSumTree()
    this.GetDictSoftwareTree()
    //this.$refs.table.doLayout()
  }, 
  /* 监听table数据对象 , 解决fixed错位问题*/
  watch: {
    tableData(val) {
      this.doLayout();
    }
  },
  methods: {
    async getSystemData(){
      const res = await connrequest('GetParamThreshhold')
      res.Data = res.Data || []
      res.Data.map( item  => {
        this.SystemData[item.Name] = item.Value
      })
      this.SystemData.cach_log_save_seconds = this.SystemData.cach_log_save_seconds / 3600 || 0
    },
    doLayout(){
      let that = this
        this.$nextTick(() => {
          that.$refs.table.doLayout()
        })
    },
    handleClick(tab){
      // console.log('点击了标签页:', tab.label,tab.index);
      if(tab.index == 0)
        this.doLayout();
    },
    handleTabClick(tab) {
      // console.log('点击了标签页:', tab.label,tab.index);
      const methodName = this.getMethodNameByTabIndex(tab.index);
      const method = this[methodName];
      if (method) {
        method(this.dialogForm);
      }
      // 在这里执行你想要的操作，可以根据需要获取更多的 tab 信息
    },
    // 根据 tab.index 获取方法名
    getMethodNameByTabIndex(tabIndex) {
      const methodNames = [
        'getDeviceData',
        'getEvent',
        'changeModer',
        'changeModer_soft',
        'getNetData',
        'getuseSoft',
        'getinstallData',
        'getillegalityData',
        'getdeficiencyData',
        'getDeviceStatus',
        'getBaseLineData',
      ];

      return methodNames[tabIndex - 1] || ''; // 注意减去1以匹配数组索引
    },
    // 获取校区树
    async GetSchoolStatusSumTree() {
      const res = await connrequest('GetSchoolStatusSumTree')
      this.formOptions.map( item => {
        if(item.label === '分区校区选择'){
          item.options = [this.transformData_assets(res.Data)]
        }
      })
    },
    // 获取子节点的校区
    async lazyLoad(node, resolve){
      if(node.level < 3){
        resolve(node.data) 
      }else{
        const data = {
          Paging:{
            QueryPageNo: 1,
            QueryPageLength: 100000
          },
          Filter:{
            SecondArea: node.label,
          }
        }
        const res = await connrequest('GetSchool', data)
        let arr = []
        res.Data.map(item => {
          arr.push( {SubClass: item.SchoolName, value: item.SchoolName, level: 4, children: undefined} )
        })
        resolve(arr) 
      }
    },
    async getData() {
      // const res = await connrequest('GetDeviceStatusSumTree')
      const res = await connrequest('GetDepartmentDeviceSumTree')
      // console.log(res);
      // return
      let partitionList = []
      let expandArray = []
      res.Data.PrimName = res.Data.RootName //因为后端返回的所有分区名字叫RootName，子菜单又叫PrimAreaName, 这里做个转换
      this.RootName = res.Data.RootName
      res.Data.disabled = true
      res.Data.edit = false
      res.Data.Department.map(item => {
        // console.log(item);
        item.edit = false
        partitionList.push(item)
        expandArray.push(res.Data.RootName, item.Name)
      })
      this.nodeData = [this.transformData(res.Data)]
      this.partitionList = partitionList
      this.expandArray = expandArray
      // console.log(this.partitionList,this.expandArray);
      this.GetDictArea(this.choseArea)
    },
    
    transformData(inputData) {
      // console.log(inputData);
      const { RootName, OffLineCount, OnlineCount, Department} = inputData;
        return {
          Name: RootName,
          level: 1,
          Count: `${OnlineCount} / ${OnlineCount + OffLineCount}`,
          Children: Department.map(area => ({
            Name: area.Name,
            Count: `${area.OnlineCount} / ${area.OnlineCount + area.OffLineCount}`,
            level: 2,
             }))
      }
    },
    transformData_assets(inputData) {
      const { RootName, PrimArea} = inputData;
        return {
          SubClass: RootName,
          value: RootName,
          level: 1,
          children: PrimArea.map(area => ({
            SubClass: area.PrimAreaName,
            value: area.PrimAreaName,
            level: 2,
            children: area.SecondArea.map(secondArea => ({
              SubClass: secondArea.SecondAreaName,
              value: secondArea.SecondAreaName,
              level: 3,
          }))
        }))
      }
    },
    process_Time(P_time)
    {
      let d = Math.floor(P_time / 3600 / 24);
      let h = Math.floor((P_time  % 86400) / 3600);
      var m = Math.floor(((P_time % 86400) % 3600) / 60);
      P_time = `${d < 1 ? '' : d}${d < 1 ? '' : '天'} ${d < 1 &&h<1? '' : h}${d < 1 &&h<1? '' : '时'} ${m}分钟`;
      return P_time
    },
    async GetDictArea(obj){
      // console.log(obj);
      const data = {
        Paging:{
          QueryPageNo: this.pageNum,
          QueryPageLength: this.pageSize
        },
        Filter:{
          // DeviceID: this.searchform?.DeviceID || '',
          DeviceName: this.searchform?.DeviceName || '',
          DeviceID: this.searchform?.DeviceID || '',
          DeviceMAC: this.searchform?.DeviceMAC || '',
          PrimArea: this.searchform?.SchoolName?.[1] || '',
          SecondArea: this.searchform?.SchoolName?.[2] || '',
          SchoolName: this.searchform?.SchoolName?.[3] || '',
          Status:  this.searchform.Status,
          OrderBy: this.searchform.Sort_value,
          // Department:this.searchform.Department,
          ...obj
        }
      }
      const res = await connrequest('CenterGetDevice', data) 
      const res1 = await connrequest('GetDepartmentDeviceSumTree') 
      this.tableData2 = this.processDataToTreedd(res1.Data,res.Data)
      // console.log(this.tableData2,res.Data);
      res.Data.map(item => {
        item.KeepRunningTime = formatDuration(item.KeepRunningTime)
        const currentTimeStamp = new Date().getTime();
        item.StatusChangeTime_redo =currentTimeStamp/1000 > item.StatusChangeTime &&item.StatusChangeTime !=0 ? formatDuration(currentTimeStamp/1000 - item.StatusChangeTime):0
      })
      this.tableData = res.Data
      this.total = res.Paging.TotalCount
    },
    processDataToTreedd(data,devicesData) {
      devicesData.sort((a, b) => a.Status - b.Status);
      const tree = {
        AgentName: data.RootName || '默认代理商',
        Department: data.RootName || '默认代理商', // 这里可能需要根据实际情况调整
        children: [], // 存放下面有哪些部门
        expand: true,
        onStatus: data.OnlineCount || 0, 
        offStatus: data.OffLineCount || 0, 
      };

      // 处理第二层节点
      data.Department.forEach(department => {
        const departmentNode = {
          Department: department.Name || '默认部门',
          ID: Math.floor(Math.random() * 10000), // 随机生成ID
          children: [],
          expand: true,
          onStatus: department.OnlineCount || 0,
          offStatus: department.OffLineCount || 0,
        };

        // 将第二层节点添加到第一层节点的 children 中
        tree.children.push(departmentNode);
        
        devicesData.forEach(item => {
          // 找到对应的部门节点
          if (item.Department === departmentNode.Department) {
            // 将设备作为子节点添加到部门节点的 children 中
            departmentNode.children.push({
              ID: Math.floor(Math.random() * 10000),
              expand: false,
              ...item,
            });
          }
        });
      });

      return tree;
    },

    renderContent(h, data) {
    if(!data.DeviceName){
      for (const key in this.departmentStats) {
        if (this.departmentStats[key].Department === data.Department) {
          data.onStatus = this.departmentStats[key].onStatus
          data.offStatus = this.departmentStats[key].offStatus
        }
      }
      return (
        <div style="width: 300px;height:100px;display:flex;padding:0;border:1px solid #2491fc;">
          <div style="width:28px;background:#2491fc;color:#fff;padding:5px;text-align:center;line-height:30px;"><p>{data.AgentName ? '公司' : '部门'}</p></div>
          <div>
            <div style="font-size:14px;line-height:20px;color:#2491fc;font-weight:600;padding-left:20px;padding-top:10px;text-align:left;">{data.Department}</div>
            <div style="font-size:14px;line-height:20px;color:#23ce69;padding-left:20px;padding-top:10px;text-align:left;">在线：{data.AgentName ? data.onStatus : data.onStatus}</div>
            <div style="font-size:14px;line-height:20px;color:#f36b6e;padding-left:20px;padding-top:10px;text-align:left;">离线：{data.AgentName ? data.offStatus : data.offStatus}</div>
          </div>
        </div>
      );
    }
    else if(data.Status === 1){
      return (
        <div style="width: 300px;height:100px;display:flex;padding:0;border:1px solid #23ce69;cursor: pointer;">
          <div style="width:28px;background:#23ce69;color:#fff;padding:5px;text-align:center;line-height:30px;"><p>在线</p></div>
          <div>
            <div style="font-size:14px;line-height:20px;color:#f36b6e;font-weight:600;padding-left:20px;padding-top:10px;text-align:left;">{data.DeviceName}   ({data.DeviceID})</div>
            <div style="font-size:14px;line-height:20px;color:#bbb;padding-left:20px;text-align:left;">{data.DeviceIP}</div>
            <div style="font-size:14px;line-height:20px;color:#bbb;padding-left:20px;text-align:left;">{formatDuration(data.KeepRunningTime)}</div>
          </div>
        </div>
      );
    }else{
      return (
        <div style="width: 300px;height:100px;display:flex;padding:0;border:1px solid #f36b6e;cursor: pointer;">
          <div style="width:28px;background:#f36b6e;color:#fff;padding:5px;text-align:center;line-height:30px;"><p>离线</p></div>
          <div>
            <div style="font-size:14px;line-height:20px;color:#f36b6e;font-weight:600;padding-left:20px;padding-top:10px;text-align:left;">{data.DeviceName}   ({data.DeviceID})</div>
            <div style="font-size:14px;line-height:20px;color:#bbb;padding-left:20px;text-align:left;">{data.DeviceIP}</div>
            <div style="font-size:14px;line-height:20px;color:#bbb;padding-left:20px;text-align:left;">{formatDuration(data.KeepRunningTime)}</div>
          </div>
        </div>
      );
    }
    
  },
    collapse(list) {
      var _this = this;
      list.forEach(function(child) {
        if (child.expand) {
          child.expand = false;
        }
        child.children && _this.collapse(child.children);
      });
    },
    onExpand(e,data) {
      if ("expand" in data) {
        data.expand = !data.expand;
        if (!data.expand && data.children) {
          this.collapse(data.children);
        }
      } else {
        this.$set(data, "expand", true);
      }
    },
    NodeClick(e, data){
      if(data.Name){
        this.LookDetails(data)
      }
    },
    handleNodeClick(nodeData){
      const {node} = nodeData
      let arr = node.level === 1 ? recursiveGetChildNodePath(node, []) : recursiveGetNodePath(node, [])
      let obj = {}
      if(node.level === 2){
        obj.Department = node.data.Name
      }
      // if(node.level === 3){
      //   obj.SecondArea = node.data.Name
      // }
      // if(node.level === 4){
      //   obj.SchoolName = node.data.Name
      // }
      this.choseArea = obj
      this.PrimArea = arr
      this.$set(this.Moder, 'PrimArea', arr)
      this.GetDictArea(this.choseArea)
    },
    handleChange(node){
      // console.log(node);
    },
    
    
    handleSizeChange(pageSize){
      this.pageSize = pageSize
      this.pageNum = 1
      this.GetDictArea(this.choseArea)
    },
    handleCurrentChange( pageNum ){
      this.pageNum = pageNum
      this.GetDictArea(this.choseArea)
    },
    toggleVisibility(isHidden) {
      if(isHidden)
        this.containerWidth = '100%';
      else 
        this.containerWidth = 'calc(100% - 240px)';
    },
    // 搜索
    search(val) {

      this.pageNum = 1
      this.searchform = {...val}
      // console.log("搜索内容",val)
      this.getData()
    },
    // 重置
    reset(){ 
      this.searchform = {}
      this.$set(this.searchform,'Status', 0)
      this.$set(this.searchform,'Sort_value','SchoolName' )
      this.$refs.connsearch.addInitValue()
      this.getData()
    },
    LookDetails(row){
      this.activeTab = 'tab1'
      this.dialogForm = {...row}
      // console.log(this.dialogForm);
      // this.$router.push({ path: '/realTimeTraffic/assetDetails', query: { Moder: this.dialogForm } });
      this.$router.push({ path: '/realTimeTraffic/assetDetails' });
      sessionStorage.setItem('detailStatus',JSON.stringify(this.dialogForm))
    },
    operateDevice(row){
      this.operatedevice = {...row}
      this.restart_Device(true)
    },
    async getuseSoft(row){
      const data = {
        Paging: {
          QueryPageNo: this.useSoftpageNum,
          QueryPageLength: this.useSoftpageSize
        },
        Filter: {
          // StartTime: this.searchform.timeRange?.[0] ||  '',
          // EndTime: this.searchform.timeRange?.[1] || '',
          PrimArea:   row.PrimArea,
          SecondArea: row.SecondArea,
          SchoolName: row.SchoolName,
          DeviceID: row.DeviceID,
          // ProcClass: this.searchform.ProcClass,
          // ProcName: this.searchform.ProcName,
          // Descp: this.searchform.Descp || '',
        }
      }
      const res = await connrequest('GetWindowProc', data)
      res.Data = res.Data || []
      res.Data = res.Data.map(item => {
        item.RunningSeconds = formatDuration(item.RunningSeconds)
        return item
      })
      this.useSoftTable = res.Data
      this.useSoftTotal = res.Paging?.TotalCount || 0
    },
    async GetDictSoftwareTree(){
      const res = await connrequest('GetDictSoftwareTree')
      let arr = [{label: '全部', value: ''}]
      res.Data.Class.map(item => {
        arr.push( {label: item.Name, value: item.Name} )
      })
      this.formOptions.map( item => {
        if(item.label === '软件分类'){
          item.options = arr
        }
      })
      this.partitionList_soft = arr
      // this.$set(this.searchform,'ProcClass', '')
    },
    changeModer_int(row){
      this.Moder = {...row, AppType: row.AppType || '必装软件'}
      this.moderVisible = true;
      // this.Moder  = row
    },
    async changeModer(row){
      const data = {
        Filter:{
          StartTime: parseTime(new Date().getTime()-this.SystemData.cach_log_save_seconds  * 60 * 60 * 1000),
          EndTime: parseTime(new Date().getTime()),
          DeviceID: row.DeviceID,
          PerfType: 1,
        }
      }
      const res = await connrequest('GetDeviceHistoryPerfStatus', data)
      let downByte = []
      let time = []
      res.Data.map(item => {
        downByte.push(item.Percent)
        time.push(parseTime(item.TransTime))
      })
      var info = '近' + this.SystemData.cach_log_save_seconds +'小时CPU使用率'
      
      this.lineData_cpu = {time, downByte,info:info}
      // console.log(this.lineData_cpu);
      // this.logDialog = true
    },
    async changeModer_soft(row){
      const data = {
        Filter:{
          StartTime: parseTime(new Date().getTime()-this.SystemData.cach_log_save_seconds  * 60 * 60 * 1000),
          EndTime: parseTime(new Date().getTime()),
          DeviceID: row.DeviceID,
          PerfType: 2,
        }
      }
      const res = await connrequest('GetDeviceHistoryPerfStatus', data)
      let downByte = []
      let time = []
      res.Data.map(item => {
        downByte.push(item.Percent)
        time.push(parseTime(item.TransTime))
      })
      var info = '近' + this.SystemData.cach_log_save_seconds +'小时内存使用率'
      this.lineData_soft = {time, downByte,info:info}
      // console.log(this.lineData_cpu);
      // this.logDialog = true
    },
    async getEvent(row){
      const data = {
        Paging: {
          QueryPageNo: this.EventpageNum,
          QueryPageLength: this.EventpageSize
        },
        Filter: { 
          "StartTime": getNowDay('time'),
          "EndTime": getNowDay('23:59:59'),
          "PrimArea": row.PrimArea,
          "SecondArea": row.SecondArea,
          "SchoolName": row.SchoolName,
          "DeviceID": row.DeviceID,
        }
      }
      const res = await connrequest('GetEventLog', data)
      res.Data = res.Data || []
      // console.log("事件汇总",res,data)
      res.Data = res.Data.map(item => {
        // 事件发生时间
        item.TransTime = formatTime2(item.TransTime)
        return item
      })
      this.eventTable = res.Data
      this.EventTotal = res.Paging.TotalCount
    },
    handleSizeChangeNet(pageSize){
      this.pageSize_net = pageSize
      this.pageNum_net = 1
      this.getNetData(this.dialogForm)
    },
    handleCurrentChangeNet( pageNum ){
      this.pageNum_net = pageNum
      this.getNetData(this.dialogForm)
    },
    handleSizeChange2(pageSize){
      this.pageSize2 = pageSize
      this.pageNum2 = 1
      this.changeMailGlobalnet(this.netInfo)
    },
    handleCurrentChange2( pageNum ){
      this.pageNum2 = pageNum
      this.changeMailGlobalnet(this.netInfo)
    },
    handleSizeChangeuse(pageSize){
      this.useSoftpageSize = pageSize
      this.useSoftpageNum = 1
      this.getuseSoft(this.dialogForm)
    },
    handleCurrentChangeuse( pageNum ){
      this.useSoftpageNum = pageNum
      this.getuseSoft(this.dialogForm)
    },
    handleSizeChange_int(pageSize){
      this.pageSize_int = pageSize
      this.pageNum_int = 1
      this.getinstallData(this.dialogForm)
    },
    handleCurrentChange_int( pageNum ){
      this.pageNum_int = pageNum
      this.getinstallData(this.dialogForm)
    },
    handleSizeChange_ill(pageSize){
      this.pageSize_ill = pageSize
      this.pageNum_ill = 1
      this.getillegalityData(this.dialogForm)
    },
    handleCurrentChange_ill( pageNum ){
      this.pageNum_ill = pageNum
      this.getillegalityData(this.dialogForm)
    },
    handleSizeChange_def(pageSize){
      this.pageSize_def = pageSize
      this.pageNum_def = 1
      this.getdeficiencyData(this.dialogForm)
    },
    handleCurrentChange_def( pageNum ){
      this.pageNum_def = pageNum
      this.getdeficiencyData(this.dialogForm)
    },
    handleSizeChange_dev(pageSize){
      this.pageSize_dev = pageSize
      this.pageNum_dev = 1
      this.getdeviciencyData(this.dialogForm)
    },
    handleCurrentChange_dev( pageNum ){
      this.pageNum_dev = pageNum
      this.getdeviciencyData(this.dialogForm)
    },
    handleSizeChange_event(pageSize){
      this.pageSize_event = pageSize
      this.pageNum_event = 1
      this.getBaseLineData(this.dialogForm)
    },
    handleCurrentChange_event( pageNum ){
      this.pageNum_event = pageNum
      this.getBaseLineData(this.dialogForm)
    },
    handleSizeChangeEvent(pageSize){
      this.EventpageSize = pageSize
      this.EventpageNum = 1
      this.getEvent(this.dialogForm)
    },
    handleCurrentChangeEvent( pageNum ){
      this.EventpageNum = pageNum
      this.getEvent(this.dialogForm)
    },
    async getDeviceData(row){
      const data = {
          Paging:{
            "QueryPageNo": 1,
            "QueryPageLength": 10
          },
          Filter:{
              "PrimArea": row.PrimArea,
              "SecondArea": row.SecondArea,
              "SchoolName": row.SchoolName,
              // "DeviceName": row.DeviceName,
              "DeviceID": row.DeviceID
          }
        }
        const res = await connrequest('GetDeviceHardware', data)
        // console.log("硬件",res);
        this.deviceForm = res.Data[0] || []
        this.deviceForm.ExtDiskSize = formatBytes_back(this.deviceForm.ExtDiskSize)
        this.deviceForm.MemSize = bytesToSize(this.deviceForm.MemSize) 
        this.deviceForm.SysDiskSize = formatBytes_back(this.deviceForm.SysDiskSize) 
    },
    async getinstallData(row){
      const data = {
          Paging:{
            "QueryPageNo": this.pageNum_int,
            "QueryPageLength": this.pageSize_int
          },
          Filter:{
              "PrimArea": row.PrimArea,
              "SecondArea": row.SecondArea,
              "SchoolName": row.SchoolName,
              "DeviceID": row.DeviceID,
              "InstallAppType":1
          }
        }   
        const res = await connrequest('GetInstallApp', data)
        const currentTimeStamp = new Date().getTime();
        res.Data = res.Data.map(item => {
          // 安装软件采集时间
          item.TransTime = formatTime2(item.TransTime)
          return item
        })
        //  console.log("安装软件",data,res);
        this.installTable = res.Data
        this.Total_int = res.Paging.TotalCount
    },
    async getillegalityData(row){
      const data = {
          Paging:{
            "QueryPageNo": this.pageNum_ill,
            "QueryPageLength": this.pageSize_ill
          },
          Filter:{
              "PrimArea": row.PrimArea,
              "SecondArea": row.SecondArea,
              "SchoolName": row.SchoolName,
              "DeviceID": row.DeviceID,
              "InstallAppType":2
          }
        }   
        const res = await connrequest('GetInstallApp', data)
        const currentTimeStamp = new Date().getTime();
        res.Data = res.Data.map(item => {
          // 非法软件采集时间
          item.TransTime = formatTime2(item.TransTime)
          return item
        })
        //  console.log("非法软件",data,res);
        this.illegalityTable = res.Data
        this.Total_ill = res.Paging.TotalCount
    },
    async getdeficiencyData(row){
      const data = {
          Paging:{
            "QueryPageNo": this.pageNum_def,
            "QueryPageLength": this.pageSize_def
          },
          Filter:{
              "PrimArea": row.PrimArea,
              "SecondArea": row.SecondArea,
              "SchoolName": row.SchoolName,
               "DeviceID": row.DeviceID,
              "InstallAppType":3
          }
        }   
        const res = await connrequest('GetInstallApp', data)
        const currentTimeStamp = new Date().getTime();
        res.Data = res.Data.map(item => {
          // 必装软件采集时间
          item.TransTime = formatTime2(item.TransTime)
          return item
        })
        
        this.deficiencyTable = res.Data
        this.Total_def = res.Paging.TotalCount
    },
    async getNetData(row){
      const data = {
          Paging:{
            "QueryPageNo": this.pageNum_net,
            "QueryPageLength": this.pageSize_net
          },
          Filter:{
              PrimArea: row.PrimArea,
              SecondArea: row.SecondArea,
              SchoolName: row.SchoolName,
              DeviceID: row.DeviceID
          }
        }
        const res = await connrequest('GetDeviceRealNetworkService', data)
        const currentTimeStamp = new Date().getTime();
        res.Data = res.Data.map(item => {
          // 网络业务检测时间
          item.TransTime = formatTime2(item.TransTime)
          return item
      })
        this.netForm = res.Data
        this.total_net = res.Paging.TotalCount
    
    },
    async getDeviceStatus(row){
      const data = {
          Paging:{
            "QueryPageNo": this.pageNum_dev,
            "QueryPageLength": this.pageSize_dev
          },
          Filter:{
              PrimArea: row.PrimArea,
              SecondArea: row.SecondArea,
              SchoolName: row.SchoolName,
              //DeviceName: row.DeviceName,
              DeviceID: row.DeviceID,
              // Status: row.Status,
          }
        }
        const res = await connrequest('GetDeviceRealNetworkService', data)
        res.Data = res.Data.map(item => {
          item.TransTime = parseTime(item.TransTime)
          return item
      })
        this.netForm = res.Data
    },
    async getDeviceStatus(row){
      const data = {
          Paging:{
            "QueryPageNo": this.pageNum_dev,
            "QueryPageLength": this.pageSize_dev
          },
          Filter:{
              PrimArea: row.PrimArea,
              SecondArea: row.SecondArea,
              // TransDate: row.TransDate,
              SchoolName: row.SchoolName,
              DeviceID: row.DeviceID,
              // DeviceID: row.DeviceID,
              // Status: row.Status,
          }
        }
        const res = await connrequest('GetDeviceStatusChangeLog', data)
        res.Data = res.Data.map(item => {
          // 状态变更发生时间
          item.TransTime = formatTime2(item.TransTime)
          return item
      })
        this.devieceStaTable = res.Data
        this.Total_dev = res.Paging.TotalCount
        // console.log("状态变更",this.devieceStaTable,data);
    },
    async getBaseLineData(row){
      this.GetBaselineFixSet()
      const data = { 
         Paging: {
          QueryPageNo: this.pageNum_event,
            QueryPageLength: this.pageSize_event
          },
          Filter: {
            PrimArea: row.PrimArea || '',
            SecondArea: row.SecondArea || '',
            SchoolName: row.SchoolName || '',
            DeviceID: row.DeviceID || '',
            // BlID: row.BlID * 1,
            BaselineNeedFix: 0,
          }
        }
        const res = await connrequest('GetDeviceRealBaselineCheck', data)
        // console.log("基线核查",res,row);
        res.Data = res.Data || []
        const currentTimeStamp = new Date().getTime();
        res.Data = res.Data.map(item => {
          // 基线核查检测时间
          item.TransTime = formatTime2(item.TransTime)
          return item
        })
        this.BaseLineForm = res.Data 
        this.Total_event = res.Paging?.TotalCount
    },
    getdeviceInfo(data){
      return (data /  1000000).toFixed(2) + 'G'
    },
    getLastLevelLeafNodes(nodeList) {
      for (const node of nodeList) {
        if (node.children && node.children.length) {
          this.getLastLevelLeafNodes(node.children);
        } else {
          // console.log(this.lastLevelLeafNodes);
          this.lastLevelLeafNodes.push(node);
        }
      }
    },
    async submit(){
      this.getLastLevelLeafNodes(this.toData)
      // console.log(this.toData,this.lastLevelLeafNodes,this.selectedSchools,this.selectedOption);
      // return 
      var result_info = []
      const selectData = Object.values(this.lastLevelLeafNodes.reduce((result, item) => {
        const [PrimArea, SecondArea, SchoolName, SchoolID, DeviceID, DeviceName] = item.info;
        
        var Item_device = {
          SchoolID: SchoolID || '',
          SchoolName: SchoolName || '',
          DeviceID: DeviceID || '',
          // DeviceName: DeviceName || '',
          Action: this.selectedOption,
          ShellCmd:this.selectedOption == 209 || this.selectedOption == 210 ?this.ShellCmd :''
        };
        result_info.push(Item_device)

        

        return result_info;
      }, {}));
      this.lastLevelLeafNodes = []
      if(selectData.length === 0)
      {
        this.$message.info('没有选择设备')
        return
      }
      const data = {
        Data: [
          ...selectData
        ],

      }
      this.$confirm('远程指令可能会导致设备侧异常，请在管理人员指导下执行。请谨慎使用。确认要对选择的设备下发远程操作指令吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        const res = await connrequest('CreateRemoteCtrl', data)
        if(res.Status.StatusCode === 0){
          this.$message.success('操作成功')
          this.dialogDeviceVisible = false
          this.getData()
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        });          
      });
    },
    async submit_soft(){
      const data = {
        Data: {
          Action: 1,
          Detail: {
            ...this.Moder,
            Name: this.Moder.AppName
          }
        }
      }
      const res = await connrequest('EditDictInstallApp', data)
      if(res.Status.StatusCode === 0){
        this.$message.success('加入字典成功')
        this.moderVisible = false
        // this.getData()
      }
    },
    handleSelectionChange(selection) {
      this.selectedSchools = selection.map(item => ({ ...item }));
    },
    async restart_Device(control){
      this.toData = []
      this.selectInfo = ''
      this.selectedOption = 200
      this.ShellCmd = ''
      this.show_shell=false
      this.selectMap = new Map()
      this.dialogDeviceVisible = true      
      const data = {
        Paging:{
          QueryPageNo: 1,
          QueryPageLength: 1000000
        },
        Filter:{
          Status: 1
        }
      }
      const res = await connrequest('CenterGetDevice', data) 
      this.arr_divece = []
      this.schoolMap = new Map() 
      if(control)
        res.Data = res.Data.filter(item => item.DeviceName != this.operatedevice.DeviceName)
      this.selectedSchools = []
      const generateRandomId = () => Math.random().toString(36).substr(2, 9);
      res.Data.map(item=>{
        let arr = {}
        arr.SchoolID = item.SchoolID
        arr.PrimArea = item.PrimArea
        this.schoolMap.set(item.Department, generateRandomId());
        arr.SecondArea = item.SecondArea
        arr.SchoolName = item.SchoolName
        arr.department = item.Department
        arr.Action = '删除未知资产'
        let arr_seconds = {}
        arr_seconds.DeviceID = item.DeviceID
        arr_seconds.DeviceName = item.DeviceName
        arr_seconds.Action = 1
        arr.Device = []
        arr.Device.push(arr_seconds)
        this.arr_divece.push(arr)
      })
      if(control)
        this.schoolMap.set(this.operatedevice.Department, generateRandomId());
      this.fromData = this.convertToTree(this.arr_divece)
      if(control)
      {
       var jsonData ={
          label:this.operatedevice.Department,
          id:this.schoolMap.get(this.operatedevice.Department),
          pid:null,
          children:[
            {
              label:this.operatedevice.DeviceName,
              id:this.operatedevice.DeviceID,
              pid:this.schoolMap.get(this.operatedevice.Department),
              info: [this.operatedevice.PrimArea, this.operatedevice.SecondArea,this.operatedevice.SchoolName, this.operatedevice.SchoolID, this.operatedevice.DeviceID, this.operatedevice.DeviceName],
            }
          ]
        }
       this.toData.push(jsonData)
       this.getLeafLabels(this.toData)
       // 使用 slice 方法去除最后一个字符
       this.selectInfo = this.selectInfo.slice(0, -1)
      }
    },
    convertToTree(flatData) {
      const tree = [];
      flatData.forEach(item => {
        const departmentNode = tree.find(node => node.label === item.department);
        if (departmentNode) {
          const deviceNode = departmentNode.children.find(node => node.label === item.Device[0].DeviceName);
          if (deviceNode) {
            // devieceName存在的情况下
          } else {
            departmentNode.children.push({
              label: item.Device[0].DeviceName,
              info: [item.PrimArea, item.SecondArea,item.SchoolName, item.SchoolID, item.Device[0].DeviceID, item.Device[0].DeviceName],
              id:item.Device[0].DeviceID,
              pid:this.schoolMap.get(item.department),
            });
          }
        } else {
          tree.push({
            label: item.department,
            id: this.schoolMap.get(item.department),
            pid: null,
            children: [
              { 
                label: item.Device[0].DeviceName,
                info: [item.PrimArea, item.SecondArea,item.SchoolName, item.SchoolID, item.Device[0].DeviceID, item.Device[0].DeviceName],
                id:item.Device[0].DeviceID,
                pid:this.schoolMap.get(item.department),
              },
            ],
          });
        }
      });
      return tree;
    },
    handleVisibleChange(row) {
      this.selectMap.set(row.SchoolID, row.Action)
      // console.log("=======",row,this.selectMap)
    },
    // 获取事件定义
    async GetParamDictEvent(){
      const res = await connrequest('GetParamDictEvent')
      let arr = []
      res.Data.map(item => {
        arr.push({label: item.AlarmDescp, value: item.EventID})
      })
      this.formOptions.map( item => {
        if(item.label === '事件类型'){
          item.options = arr
          item.initValue = arr[0]?.value
        }
      })
      this.eventList = arr
    },
    getEventLabel(eventID) {
      return this.eventList.find(item => item.value === eventID)?.label || null;
    },
    async changeMailGlobalnet(row){
      this.netInfo = {...row}
      // this.DeviceID = row.DeviceID
      const data = { 
        Paging:{
          QueryPageNo: this.pageNum2,
          QueryPageLength: this.pageSize2
        },
        Filter:{
          DeviceID: row.DeviceID,
          NetworkServiceName: row.ServiceName
        }
      }
      const res = await connrequest('GetDeviceHistoryNetworkService', data)
      res.Data = res.Data.map(item => {
        item.TransTime = formatTime2(item.TransTime)
        return item
      })
      this.logList = res.Data
      this.total2 = res.Paging?.TotalCount
      this.logDialognet = true
    },
    async changeMailGlobal(row){
      // console.log(row);
      // return
      const data = {
        Data: [row.AutoID]
      }
      const res = await connrequest('ConfirmEvent', data)
      if (res.Status.StatusCode === 0) {
        this.$message.success('确认成功')
        // this.getData()
        this.getEvent(this.dialogForm)
      }
    },
    async changeMailGlobalBase(row){
      // console.log(row);
      this.BaseLineinfo = {...row}
      this.BashLineShow = true
    },
    async changeMailGlobalAll(){
      const arr = this.eventTable.map(item => item.AutoID);
      const data = {
        Data: arr
      }
      const res = await connrequest('ConfirmEvent', data)
      if (res.Status.StatusCode === 0) {
        this.getEvent(this.dialogForm)
        this.$message.success('确认成功')
        // this.getData()
      }
    },
    handleSelectChange(val){
      // console.log(val);
      if(val === 209 || val === 210) this.show_shell = true
      else this.show_shell = false 
    },
    async GetBaselineFixSet(){
      const res = await connrequest('GetBaselineFixSet')
      let arr = []
      res.Data.BaselineResult.map(item => {
        arr.push({ label: item.Subject, value: item.id * 1, FixScheme: item.FixScheme })
      })
      this.formOptions.map( item => {
        if(item.label === '检测项目'){
          item.options = [{label: '全部', value: '', FixScheme: ''}, ...arr]
        }
      })
      this.BaselineResultList = arr
    },
    findBaselineLabel(BlID) {
      const baselineItem = this.BaselineResultList.find(item => item.value === BlID);
      return baselineItem ? baselineItem.label : '';
    },
     findBaselineFixScheme(BlID) {
      const baselineItem = this.BaselineResultList.find(item => item.value === BlID);
      return baselineItem ? baselineItem.FixScheme : '';
    },
    addSelect(fromData,toData,obj){
      this.selectInfo = ''
      this.getLeafLabels(this.toData)
      // 使用 slice 方法去除最后一个字符
      this.selectInfo = this.selectInfo.slice(0, -1)
    },
    removeSelect(fromData,toData,obj){
      this.selectInfo = ''
      this.getLeafLabels(this.toData)
      // 使用 slice 方法去除最后一个字符
      this.selectInfo = this.selectInfo.slice(0, -1)
    },
    getLeafLabels(nodes) {
      for (const node of nodes) {
        if (node.children && node.children.length > 0) {
          this.getLeafLabels(node.children);
        } else {
          this.selectInfo += node.label + "、";;
        }
      }
    },
    editShell(){
      this.editShow = true
    }
  }
};
</script>
<style scoped>
.box {
  background-color: lightblue;
  transition: width 0.5s; /* 添加过渡动画 */
}
.wl-transfer .transfer-title,
.wl-transfer ::v-deep .transfer-title {
  font-size: 14px !important;
  margin: 0 !important;
}
::v-deep .el-progress-bar {
  width: 70%; /* 设置进度条的宽度 */
  /* 添加其他样式属性 */
}
::v-deep .el-descriptions-item__label.is-bordered-label{
  width: 200px;
}
::v-deep .el-descriptions__header{
   margin-bottom: 10px;
}


/*  dialog*/
.el-dialog__header {
  padding: 15px 20px 15px;
}
.el-dialog__headerbtn{
  top: 15px;
}
 
/* dialog header */
.avue-crud__dialog__header {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
}
.el-dialog__title {
  color: rgba(0,0,0,.85);
  font-weight: 500;
  word-wrap: break-word;
}
.avue-crud__dialog__menu {
  padding-right: 35px;
  float: left;
}
.avue-crud__dialog__menu i {
  color: white;
  font-size: 15px;
}
.el-icon-full-screen{
  cursor: pointer;
}
.el-icon-full-screen:before {
  content: "\e719";
}
.el-icon-copy-document{
  cursor: pointer;
}
</style>
 